package com.tudouji.project.farepay.controller;

import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.framework.web.page.TableDataInfo;
import com.tudouji.project.farepay.domain.FarepayDetails;
import com.tudouji.project.farepay.service.IFarepayDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物流运费付款申请明细Controller
 *
 * @author tudouji
 * @date 2021-10-27
 */
@RestController
@RequestMapping("/farepay/farepayitem")
public class FarepayDetailsController extends BaseController
{
    @Autowired
    private IFarepayDetailsService farepayDetailsService;

    /**
     * 查询物流运费付款申请明细列表
     */
    @PreAuthorize("@ss.hasPermi('farepay:farepayitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(FarepayDetails farepayDetails)
    {
        startPage();
        List<FarepayDetails> list = farepayDetailsService.selectFarepayDetailsList(farepayDetails);
        return getDataTable(list);
    }

    /**
     * 导出物流运费付款申请明细列表
     */
    @PreAuthorize("@ss.hasPermi('farepay:farepayitem:export')")
    @Log(title = "物流运费付款申请明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FarepayDetails farepayDetails)
    {
        List<FarepayDetails> list = farepayDetailsService.selectFarepayDetailsList(farepayDetails);
        ExcelUtil<FarepayDetails> util = new ExcelUtil<FarepayDetails>(FarepayDetails.class);
        return util.exportExcel(list, "farepayitem");
    }

    /**
     * 获取物流运费付款申请明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('farepay:farepayitem:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(farepayDetailsService.selectFarepayDetailsById(guid));
    }

    /**
     * 修改物流运费付款申请明细
     */
    @PreAuthorize("@ss.hasPermi('farepay:farepayitem:edit')")
    @Log(title = "物流运费付款申请明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FarepayDetails farepayDetails)
    {
        return toAjax(farepayDetailsService.updateFarepayDetails(farepayDetails));
    }

    /**
     * 新增物流运费付款申请明细
     * 参数：farepayGuid  wlinfoids
     */
    @Log(title = "物流运费付款申请明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FarepayDetails farepayDetails)
    {
        return farepayDetailsService.insertFarepayDetails(farepayDetails);
    }
    /**
     * 删除物流运费付款申请明细
     */
    @Log(title = "物流运费付款申请明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return farepayDetailsService.deleteFarepayDetailsByIds(guids);
    }
}
